package csu.rjxyg.action.infoAction;

import java.util.List;

import csu.rjxyg.action.BaseAction;
import csu.rjxyg.action.constant.UserConstant;
import csu.rjxyg.bean.core.BaseList;
import csu.rjxyg.bean.core.BaseObject;
import csu.rjxyg.factory.core.UtilFactory;
import csu.rjxyg.service.BaseInfoService;
import csu.rjxyg.util.LogUtil;

public class GetInfoAction extends BaseAction{
	private LogUtil log;	
	
	public GetInfoAction(){
		log = UtilFactory.getLogUtil(this.getClass());
	}
	
	public void getAllAcceptInfo(){
		String name = null;
		BaseList temp = null;
		try{
			BaseObject object = (BaseObject) this.getSession().get(UserConstant.USER_SESSION);
			name = (String) object.get(UserConstant.USER_ID);
			List acceptList =  (List) object.get(UserConstant.USER_ACCEPT_INFO);
			if(acceptList != null){
				if( acceptList.size() == 0 ){
					return;
				}
				BaseInfoService baseInfoService = (BaseInfoService) factory.getBean(INFO_SERVICE);
				temp = baseInfoService.getAllInfoById(acceptList, 1);
				this.out(temp.getBean().toString());
			}			

			log.info(name + "查询所有的收件箱信息成功");
		}catch(Exception e){
			log.info(name + "查询所有的收件箱信息失败");
			e.printStackTrace();
			log.info(e.getMessage());
		}
	}
	
	
	public void getAllSendInfo(){
		String name = null;
		BaseList temp = null;
		try{
			BaseObject object = (BaseObject) this.getSession().get(UserConstant.USER_SESSION);
			name = (String) object.get(UserConstant.USER_ID);
			List sendList =  (List) object.get(UserConstant.USER_SEND_INFO);
			if(sendList != null){
				if( sendList.size() == 0 ){
					return;
				}
				BaseInfoService baseInfoService = (BaseInfoService) factory.getBean(INFO_SERVICE);
				temp = baseInfoService.getAllInfoById(sendList, 2);
				this.out(temp.getBean().toString());
			}			
			
			log.info(name + "查询所有的发件箱信息成功");
		}catch(Exception e){
			log.info(name + "查询所有的发件箱信息失败");
			e.printStackTrace();
			log.info(e.getMessage());
		}
	}
}
